﻿
@{
    ViewBag.Title = "应用编辑";
    Layout = "~/Views/Shared/_ManagerLayoutPage.cshtml";


    var app = ViewData["App"] == null ? null : ViewData["App"] as BaseAuthRole.DTO.Auth.ApplicationModel;
}

<div class="row">
    <div class="col-md-12">
        <div class="card">
            <div class="card-body" style="padding: 1.75rem 2.8125rem;">
                <div class="row">
                    <div class="col-md-12">
                        <p style="font-size:15px;font-weight:bold;">@(app==null?"添加应用":"修改应用")</p>
                        <div class="form-group ">
                            <lable class="col-sm-2 control-lable require">应用名称</lable>
                            <div class="col-sm-4">
                                <input id="name" class="form-control" value="@(app==null?"":app.Name)">
                            </div>
                        </div>
                        <div class="form-group">
                            <lable class="col-sm-2 control-lable require">简介</lable>
                            <div class="col-sm-4">
                                <textarea id="des" class="form-control" rows="6">@(app==null?"":app.Description)</textarea>
                            </div>
                        </div>

                        <div class="form-group ">
                            <lable class="col-sm-2 control-lable require">回调地址</lable>
                            <div class="col-sm-4">
                                <input class="form-control" value="@(app==null?"":app.AuthDomain)" id="auth_domain"  placeholder="多个回调域名以;分割">
                            </div>
                        </div>
                        <div class="form-group">

                            <div class="col-sm-4 col-sm-offset-2">
                                <button class="btn btn-success" id="basic_submit" type="button">保存</button>
                            </div>
                        </div>
                    </div>

                </div>

            </div>
        </div>
    </div>
</div>


@section ChildPageScript
    {
    


    <script>
        var id = "@(app==null?"":app.Id)";

        $("#basic_submit").click(function ()
        {


            var name = $("#name").val();

            var des = $("#des").val();

            var auth_domain = $("#auth_domain").val();


            if (name == "" || des == "" || auth_domain == "")
            {

                Notic('error','必要参数不能为空');

                return;
            }

            $("#basic_submit").attr("disabled", "disabled");

            $.ajax({

                url: "@RS.Environment.ConfigurationHelper.GetAppSettings("VirtualUrl")" + "/AppManager/EditApp",
                data: { "name": name, "des": des, "auth_domain": auth_domain,"id":id},
                dataType: "json",
                type: "post",
                success: function (data)
                {
                    if (data.IsError)
                    {
                        Notic('error', data.Message);   

                        $("#basic_submit").removeAttr("disabled");

                    }
                    else
                    {

                        location = "@RS.Environment.ConfigurationHelper.GetAppSettings("VirtualUrl")" + "/AppManager/AppDetail?id="+data.Result;

                    }

                }               
            });


        });




    </script>
    
    
    
    }

